﻿CREATE FUNCTION [sp_ssiscatalog].[get_status_desc_from_status]
(
	@status_id		int
)
RETURNS	TABLE AS
		RETURN
		SELECT	[status_desc]=	CONVERT(NVARCHAR(MAX),		CASE	WHEN	@status_id	=	1		THEN	N'created'
																	WHEN	@status_id	=	2		THEN	N'running'
																	WHEN	@status_id	=	3		THEN	N'canceled'
																	WHEN	@status_id	=	4		THEN	N'failed'
																	WHEN	@status_id	=	5		THEN	N'pending'
																	WHEN	@status_id	=	6		THEN	N'ended unexpectedly'
																	WHEN	@status_id	=	7		THEN	N'succeeded'
																	WHEN	@status_id	=	8		THEN	N'stopping'
																	WHEN	@status_id	=	9		THEN	N'completed'
																	ELSE	NULL
															END
								)                                                    